package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.ui.contract.TaskingContract
import com.baizan.daka.mvp.model.MyTaskModel
import com.baizan.daka.mvp.model.NewsModel
import com.baizan.daka.mvp.model.bean.NewsInfoBean
import com.baizan.daka.mvp.model.bean.TaskInfoBean
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast
import com.baizan.daka.ui.contract.NewsContract

class NewsPresenter(val mView: NewsContract.View) : BasePresenter(),
    NewsContract.Presenter {
    val newsModel: NewsModel by lazy { NewsModel() }

    override fun loadNewsList( pageNo:Int) {
        newsModel.loadNewslist(pageNo)
            .subscribe(object :
                CommonSubscriber<BasePageResponse<NewsInfoBean>>(compositeDisposable) {

                override fun onCallNext(t: BasePageResponse<NewsInfoBean>?) {
                    mView.loadNewsListSuccess(t!!)
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    mView.loadNewsListFail()
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                    mView.hideLoadingDialog()
                }
            })

    }

}